package interfaces.loading;

import fileHandling.language.Lang;
import fileHandling.language.LanguageLoader;
import interfaces.GUISource;
import interfaces.WordWrapHelper;
import interfaces.superWidgets.InterfaceLabel;

import org.fenggui.binding.render.ImageFont;
import org.fenggui.layout.StaticLayout;

import main.GameCycle;
import map.Map;

public class GameModeWindow extends LoadingWindow {
	
	private ImageFont labelFont;
	private GameCycle gameCycle;
	
	public GameModeWindow(Map map, GameCycle gameCycle, String titleText, int width, int height) {
		super(map, titleText);
		this.gameCycle = gameCycle;
		
		setSize(width, height);
		
		labelFont = GUISource.middleFont;
		
		content.setLayoutManager(new StaticLayout());
		layout();
		
		init();
		
		layout();
	}
	
	private void init() {
		int border = content.getWidth() / 40;
		int labelWidth = content.getWidth() - border * 2;
		int labelHeight = labelFont.getHeight();
		
		Lang modeLang = gameCycle.getGameMode().getGameModeDescription();
		String modeString = LanguageLoader.get(modeLang);
		InterfaceLabel modeLabel = new InterfaceLabel(labelFont);
		modeLabel.setSize(labelWidth, labelHeight);
		modeLabel.setX(border);
		WordWrapHelper.wrapWords(modeLabel, modeString);
		labelHeight *= modeLabel.getText().split("\n").length;
		modeLabel.setHeight(labelHeight);
		modeLabel.setY(content.getHeight() - labelHeight - border);
		content.addWidget(modeLabel);
	}
}